package com.jdz.service.impl;

import com.google.common.collect.Lists;
import com.jdz.common.ServerResponse;
import com.jdz.dao.InstituteMapper;
import com.jdz.dao.ProfessionMapper;
import com.jdz.pojo.Institute;
import com.jdz.pojo.Profession;
import com.jdz.service.IProfessionService;

import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by sun
 **/
@Service("IProfessionService")
public class ProfessionServiceImpl implements IProfessionService {
    @Autowired
    InstituteMapper instituteMapper;
    @Autowired
    ProfessionMapper professionMapper;

    private Logger logger = LoggerFactory.getLogger(ProfessionServiceImpl.class);


//    private ProfessionVo assemblePprofessionVo(Profession profession){
//        ProfessionVo professionVo = new ProfessionVo();
//        professionVo.setProfessionname(profession.getProfessionname());
//        return professionVo;
//    }`

    @Override
    public ServerResponse<List<Profession>> list(String stuInstitutename) {

        Institute institute = instituteMapper.selectInstituteName(stuInstitutename);

        List<Profession> professionList = professionMapper.selectList(institute.getStuinstituteno());

        if(CollectionUtils.isEmpty(professionList)){
            logger.info("未找到专业");
        }


        return ServerResponse.createBySuccess(professionList);
    }
}
